package com.huiyi.order.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.huiyi.common.annotation.Log;
import com.huiyi.common.core.controller.BaseController;
import com.huiyi.common.core.domain.AjaxResult;
import com.huiyi.common.enums.BusinessType;
import com.huiyi.order.domain.AppointmentOrder;
import com.huiyi.order.service.IAppointmentOrderService;
import com.huiyi.common.utils.poi.ExcelUtil;
import com.huiyi.common.core.page.TableDataInfo;

/**
 * 诊断管理Controller
 * 
 * @author zfz
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/order/order")
public class AppointmentOrderController extends BaseController
{
    @Autowired
    private IAppointmentOrderService appointmentOrderService;

    /**
     * 查询诊断管理列表
     */
    @PreAuthorize("@ss.hasPermi('order:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppointmentOrder appointmentOrder)
    {
        startPage();
        List<AppointmentOrder> list = appointmentOrderService.selectAppointmentOrderList(appointmentOrder);
        return getDataTable(list);
    }

    /**
     * 导出诊断管理列表
     */
    @PreAuthorize("@ss.hasPermi('order:order:export')")
    @Log(title = "诊断管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppointmentOrder appointmentOrder)
    {
        List<AppointmentOrder> list = appointmentOrderService.selectAppointmentOrderList(appointmentOrder);
        ExcelUtil<AppointmentOrder> util = new ExcelUtil<AppointmentOrder>(AppointmentOrder.class);
        util.exportExcel(response, list, "诊断管理数据");
    }

    /**
     * 获取诊断管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:order:query')")
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") Long orderId)
    {
        return success(appointmentOrderService.selectAppointmentOrderByOrderId(orderId));
    }

    /**
     * 新增诊断管理
     */
    @PreAuthorize("@ss.hasPermi('order:order:add')")
    @Log(title = "诊断管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppointmentOrder appointmentOrder)
    {
        System.out.println(appointmentOrder.toString());
        return toAjax(appointmentOrderService.insertAppointmentOrder(appointmentOrder));
    }

    /**
     * 修改诊断管理
     */
    @PreAuthorize("@ss.hasPermi('order:order:edit')")
    @Log(title = "诊断管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppointmentOrder appointmentOrder)
    {
        System.out.println(appointmentOrder.toString());
        return toAjax(appointmentOrderService.updateAppointmentOrder(appointmentOrder));
    }
    /**
     * 删除诊断管理
     */
    @PreAuthorize("@ss.hasPermi('order:order:remove')")
    @Log(title = "诊断管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable Long[] orderIds)
    {
        return toAjax(appointmentOrderService.deleteAppointmentOrderByOrderIds(orderIds));
    }
}
